package io.gitee.zhangbinhub.acp.cloud

import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import io.gitee.zhangbinhub.acp.cloud.constant.AcpCloudConstant
import io.gitee.zhangbinhub.acp.cloud.lock.DistributedLock
import io.gitee.zhangbinhub.acp.cloud.lock.RedisDistributedLock
import org.noear.solon.annotation.Bean
import org.noear.solon.annotation.Condition
import org.noear.solon.annotation.Configuration
import org.noear.solon.annotation.Inject
import org.redisson.api.RedissonClient

@Configuration
class AcpCloudDistributedLockAutoConfiguration {
    @Bean
    @Condition(onMissingBean = DistributedLock::class, priority = AcpCloudConstant.DISTRIBUTED_LOCK_COMPONENT_PRIORITY)
    fun redisDistributedLock(@Inject logAdapter: LogAdapter, @Inject redissonClient: RedissonClient): DistributedLock =
        RedisDistributedLock(logAdapter, redissonClient)
}